/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ucb.sispro.model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author felipe
 */
@Entity
@Table(name = "perguntaavaliacao")
@NamedQueries({
    @NamedQuery(name = "PerguntaAvaliacao.findAll", query = "SELECT p FROM PerguntaAvaliacao p"),
    @NamedQuery(name = "PerguntaAvaliacao.findByIdPerguntaAvaliacao", query = "SELECT p FROM PerguntaAvaliacao p WHERE p.idPerguntaAvaliacao = :idPerguntaAvaliacao"),
    @NamedQuery(name = "PerguntaAvaliacao.findByPergunta", query = "SELECT p FROM PerguntaAvaliacao p WHERE p.pergunta = :pergunta")})
public class PerguntaAvaliacao implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idPerguntaAvaliacao")
    private Integer idPerguntaAvaliacao;
    @Basic(optional = false)
    @Column(name = "pergunta")
    private String pergunta;
    @JoinTable(name = "perguntaavaliacaoavaliacao", joinColumns = {
        @JoinColumn(name = "PerguntaAvaliacao_idPerguntaAvaliacao", referencedColumnName = "idPerguntaAvaliacao")}, inverseJoinColumns = {
        @JoinColumn(name = "Avaliacao_idAvaliacao", referencedColumnName = "idAvaliacao")})
    @ManyToMany
    private List<Avaliacao> avaliacaoList;
    @JoinTable(name = "perguntaavaliacaoestabelecimento", joinColumns = {
        @JoinColumn(name = "PerguntaAvaliacao_idPerguntaAvaliacao", referencedColumnName = "idPerguntaAvaliacao")}, inverseJoinColumns = {
        @JoinColumn(name = "Estabelecimento_idEstabelecimento", referencedColumnName = "idEstabelecimento")})
    @ManyToMany
    private List<Estabelecimento> estabelecimentoList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "perguntaAvaliacaoidPerguntaAvaliacao")
    private List<RespostaAvaliacao> respostaAvaliacaoList;

    public PerguntaAvaliacao() {
    }

    public PerguntaAvaliacao(Integer idPerguntaAvaliacao) {
        this.idPerguntaAvaliacao = idPerguntaAvaliacao;
    }

    public PerguntaAvaliacao(Integer idPerguntaAvaliacao, String pergunta) {
        this.idPerguntaAvaliacao = idPerguntaAvaliacao;
        this.pergunta = pergunta;
    }

    public Integer getIdPerguntaAvaliacao() {
        return idPerguntaAvaliacao;
    }

    public void setIdPerguntaAvaliacao(Integer idPerguntaAvaliacao) {
        this.idPerguntaAvaliacao = idPerguntaAvaliacao;
    }

    public String getPergunta() {
        return pergunta;
    }

    public void setPergunta(String pergunta) {
        this.pergunta = pergunta;
    }

    public List<Avaliacao> getAvaliacaoList() {
        return avaliacaoList;
    }

    public void setAvaliacaoList(List<Avaliacao> avaliacaoList) {
        this.avaliacaoList = avaliacaoList;
    }

    public List<Estabelecimento> getEstabelecimentoList() {
        return estabelecimentoList;
    }

    public void setEstabelecimentoList(List<Estabelecimento> estabelecimentoList) {
        this.estabelecimentoList = estabelecimentoList;
    }

    public List<RespostaAvaliacao> getRespostaAvaliacaoList() {
        return respostaAvaliacaoList;
    }

    public void setRespostaAvaliacaoList(List<RespostaAvaliacao> respostaAvaliacaoList) {
        this.respostaAvaliacaoList = respostaAvaliacaoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idPerguntaAvaliacao != null ? idPerguntaAvaliacao.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof PerguntaAvaliacao)) {
            return false;
        }
        PerguntaAvaliacao other = (PerguntaAvaliacao) object;
        if ((this.idPerguntaAvaliacao == null && other.idPerguntaAvaliacao != null) || (this.idPerguntaAvaliacao != null && !this.idPerguntaAvaliacao.equals(other.idPerguntaAvaliacao))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "br.ucb.sispro.model.PerguntaAvaliacao[ idPerguntaAvaliacao=" + idPerguntaAvaliacao + " ]";
    }
    
}
